#!/bin/bash

echo "安装必要的软件包..."
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
echo "必要的软件包安装完成。"

echo "添加Docker的yum仓库..."
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
echo "Docker的yum仓库添加完成。"

echo "更新yum缓存..."
sudo yum makecache fast
echo "yum缓存更新完成。"

echo "安装Docker CE..."
sudo yum install -y docker-ce
echo "Docker CE安装完成。"

echo "启动Docker服务..."
sudo systemctl start docker
echo "Docker服务启动完成。"

echo "将Docker服务设置为开机启动..."
sudo systemctl enable docker
echo "Docker服务设置为开机启动完成。"

echo "验证Docker安装..."
docker_version=$(sudo docker --version)
echo "Docker安装成功，版本信息：$docker_version"

echo "所有操作已完成，Docker CE已成功安装并启动。"
